package com.meizi.mall.search.controller;

import com.meizi.core.tool.api.R;
import com.meizi.mall.common.status.EsStatus;
import com.meizi.mall.common.to.es.SkuEsModel;
import com.meizi.mall.search.service.ProductSaveService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author meizi
 * @email enjoymeizi@gmail.com
 * @date 2021/1/20 16:16
 */
@RestController
@RequestMapping("search")
public class ProductController {
    @Autowired
    ProductSaveService productSaveService;


    @PostMapping("product/status/up")
    public R productStatusUp(@RequestBody List<SkuEsModel> listSkuModel){
        try {
            Boolean aBoolean = productSaveService.productStatusUp(listSkuModel);
            if(!aBoolean){
                return R.ok();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return    R.ofStatus(EsStatus.SAVE_ERROR);
    }
}
